﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pesico.Forms.Entities;
using Microsoft.SharePoint;
using T2V.SharePoint.Common.Utilities;
using T2V.SharePoint.Common.Utilities.Camlex;
using Pesico.Forms.Common;

namespace Pesico.Forms.Services
{
    public class ApproverWorkflowMapping
    {
        public static ApproverWorkflowMappingItem GetItemByCreator(string creator, SPWeb web)
        {
            SPList list = Utility.GetListFromURL(Constants.APPROVER_WORKFLOW_MAPPING_LIST_URL, web);
            if (list == null) return null;
            CAMLListQuery<ApproverWorkflowMappingItem> query = new CAMLListQuery<ApproverWorkflowMappingItem>(list);

            string caml = Camlex.Query().Where(x => x["Creator"] == (DataTypes.UserId)creator).ToString();
            return query.ExecuteSingleQuery(caml);
        }
    }
}
